#!usr/bin/env python
#coding=utf8
"""
@描述：用类结构做行业标签json格式
@日期：2015年01月28日 星期三
@作者：hongxingfan
"""

import sys


class Item(object):
	'''
	一级标签
	'''
	def __init__(self,name,code):
		self.code = code
		self.name = name

	def __eq__(self, oth):
		return self.name == oth.name and self.code == oth.code
	def __hash__(self):
		return hash(self.name + "," + str(self.code))

class children:
	def __init__(self,name,code):
		self.code = code
		self.name = name

if __name__ == "__main__":
	#conn = MySQLdb.connect(host="")
	key_value = {}
	
	parent1 = Item("changqingfan",1)
	l = []
	child1 = children("hongxingfan",10)
	l.append(child1)
	key_value[parent1] = l

	# 添加两个相同对象，则前一个配挤掉
	parent1 = Item("changqingfan",1)
	lll = []
	child1 = children("hongxingfan",10)
	lll.append(child1)
	key_value[parent1] = lll

	ll = []
	child1 = children("shulicheng",20)
	ll.append(child1)
	child1 = children("shuyingcheng",21)
	ll.append(child1)
	child1 = children("shumincheng",22)
	ll.append(child1)
	parent2 = Item("guofucheng",2)
	key_value[parent2] = ll

	for (k,v) in key_value.items():
		print(str(k.code) + ":" + k.name + "-->"),
		for vv in v:
			#print(vv)
			print(str(vv.code) + ":" + vv.name + ">>"),
		print("")
